using UnityEngine;
using System.Collections;

public class HighscoreSubmitter : MonoBehaviour {
    public const string endpoint = "http://atcbrisbaneisac.appspot.com/";
    public string player_name;
    public int score;
    public int seed;
    public static GameObject g = null;

    public static void CreateSubmitter(string player_name, int seed, int score) {
		if (g == null) {
            g = new GameObject();
        }
        HighscoreSubmitter s = g.AddComponent<HighscoreSubmitter>();
        s.player_name = player_name;
        s.score = score;
        s.seed = seed;
    }

    IEnumerator Start() {
        var f = new WWWForm();
        f.AddField("name", player_name);
        f.AddField("score", score);
        f.AddField("seed", seed);
        WWW www = new WWW(endpoint, f);
        yield return www;
        // XXX no error handling
    }
}
